﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Drawing;
using System.IO;
using Rectangle = Microsoft.Xna.Framework.Rectangle;
using Color = Microsoft.Xna.Framework.Color;
using xml_classes;
namespace QuestPrototype
{
    class GameScreen
    {
        private List<Polygon> Polygons;

        public List<Polygon> Polygons1
        {
            get { return Polygons; }
            set { Polygons = value; }
        }
        private Vector3 ViewerPosition;
        private List<Item> Items;
        private List<Character> Characters;
        Texture2D screenTexture;
        public byte[,] wallGrid;

        #region GameScreen constructors
        public GameScreen(Texture2D _screenTexture, string _wallMapPath)
        {
            screenTexture = _screenTexture; 
            Bitmap bitmap = new Bitmap(_wallMapPath);
            
            wallGrid = new byte[bitmap.Width/2, bitmap.Height/2];
            int x, y;
            for (x = 0; x < bitmap.Width; x=x+2)
            {
                for (y = 0; y < bitmap.Height; y=y+2)
                {

                    System.Drawing.Color currentcolor = bitmap.GetPixel(x, y);
                    //Console.WriteLine(x + " " + y + " " + currentcolor.Name);
                    switch (currentcolor.Name)
                    {
                        case "ffffffff"://1
                            {
                                wallGrid[x/2, y/2] = 1;
                            }
                            break;
                        case "ff000000"://wall
                            {
                                wallGrid[x/2, y/2] = 0;
                            }
                            break;
                        default:
                            {
                                wallGrid[x/2, y/2] = 13;
                            }
                            break;
                    }
                }
            }

        }
        #endregion

        #region Screen Draw
        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(screenTexture, new Rectangle(0, 0, 1280, 720), Color.White);
        }
        #endregion
    }
}